<?php

/**
 * evenement form.
 *
 * @package    e-DSL
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrinePluginFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class evenementForm extends PluginevenementForm
{
  public function configure()
  {
  }
  
  public function prepareToAssign(){
  	$i18N = sfContext::getInstance()->getI18N();
  	$objDef = new objectDef('evenement');
  	$user = sfContext::getInstance()->getUser()->getUserProfile();
  	foreach($objDef->attributes as $fieldName => $att){
		if($fieldName=='owner_id'){
			$objDef->attributes[$fieldName]['show']=true;
			$q=Doctrine_Query::create()
			    ->select('a.id as id, a.nom  as name')
				->from('client a') 
				->orderBy('a.nom');
			$q->andWhere('a.commercial_id = ' . $user->id);
			$q->andWhere('a.activeStatus = 0');
			$this->widgetSchema[$fieldName] = new sfWidgetFormDoctrineChoice(
		 								array('model' => 'client',
		 								'query' => $q,
		 								'add_empty' => sfContext::getInstance()->getI18N()->__('Please select a value...')));
		 	$this->widgetSchema[$fieldName]->setLabel('Client');
		 	$helps = $this->widgetSchema->getHelps();
		 	if($att['help']==''){$helps[$fieldName] = ' ';}else{ $helps[$fieldName] = utf8_decode($i18N->__($att['help'],null,'forms'));};
		 	$this->widgetSchema->setHelps($helps);
		 	$attributes['class'] = 'combobox form required';		
		 	$attributes['tmt:invalidindex'] = '';
		 	$attributes['tmt:message'] .= $i18N->__("Required Attribute"); 
			$this->offsetGet($fieldName)->getWidget()->setAttributes($attributes);
		}elseif($fieldName=='type'){
		
		}elseif($fieldName=='description'){
		
  		
  		}else{
			$this->hideWidget($fieldName);
		}
	}
  }
}
